<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    request.setAttribute("contextPath", request.getContextPath());
%>
<script type="text/javascript">
    $(function () {
        $("#start,#end").datepicker(
                $.extend({}, $.datepicker.regional["en-US"],
                        {
                            dateFormat:"yy-mm-dd",
                            showOn:"both",
                            buttonImage:"${contextPath}/static/images/calendar.gif",
                            buttonImageOnly:true
                        }));
    });

    function search() {
        $("input:checkbox").each(function () {
            $(this).val($(this).attr("checked"));
        });
        document.forms[0].submit();
    }
</script>
<h1>Request Log</h1>

<div class="main">
    <div class="box_side search_hotel clearfix">
        <table id="counter">
            <tr>
                <td>Total</td>
                <td>RealCheckCount</td>
                <td>NoAllotmentCount</td>
                <td>QueryCacheCount</td>
                <td>MaxOccRestrictedCount</td>
                <td>RateHitCount</td>
                <td>RoomStayFilteredCount</td>
                <td>RealCheck</td>
                <td>FromCache</td>
                <td>MaxOccRestricted</td>
                <td>RateHit</td>
                <td>RoomStayFiltered</td>
            </tr>
            <tr>
                <td>-${availRequestCounter.totalCount}-</td>
                <td>${availRequestCounter.realCheckCount}-</td>
                <td>${availRequestCounter.noAllotmentCount}-</td>
                <td>${availRequestCounter.queryCacheCount}-</td>
                <td>${availRequestCounter.maxOccRestrictedCount}-</td>
                <td>${availRequestCounter.rateHitCount}-</td>
                <td>${availRequestCounter.roomStayFilteredCount}-</td>
                <td>${availRequestCounter.realCheck}</td>
                <td>${availRequestCounter.fromCache}</td>
                <td>${availRequestCounter.maxOccRestricted}</td>
                <td>${availRequestCounter.rateHit}</td>
                <td>${availRequestCounter.roomStayFiltered}</td>
            </tr>
        </table>
    </div>
</div>

<div class="main">

    <div class="box_side search_hotel clearfix">
        <form method="get" action="">
            <ul>
                <li><label>Type : </label>
                    <s:select name="requestCondition.code"
                              list="@com.derbysoft.lowcostadapter.commons.model.OperationType@values()"/>
                </li>
                <li>
                    <label>Start~End : </label>
                    <s:textfield name="requestCondition.start" id="start" size="10"
                                 autocomplete="off"/>~
                    <s:textfield name="requestCondition.end" id="end" size="10"
                                 autocomplete="off"/>
                </li>
                <li>
                    <label>Task Id : </label>
                    <s:textfield name="requestCondition.taskId" size="35"/>
                </li>
                <li><label>HasError : <input type="checkbox" name="requestCondition.hasError"
                                             <s:if test="requestCondition.hasError">checked="checked" </s:if>/></label>
                </li>
                <li>
                    <label>Hotel Code : </label>
                    <s:textfield name="requestCondition.hotelCode" size="30"/>
                </li>
                <li>
                    <label>Ersp No : </label>
                    <s:textfield name="requestCondition.erspNo" cssClass="text"/>
                </li>
                <li>
                    <label>Spend Time : </label>
                    <s:textfield name="requestCondition.minSpentTime" size="5"/> to <s:textfield
                        name="requestCondition.maxSpentTime" size="5"/>
                </li>
            </ul>
            <input type="button" onclick="search();" value="Search" class="common_button"/>
        </form>
    </div>
</div>
<div class="main">
    <jsp:include page="../../common/pagination.jsp"/>
    <table id="channel" class="table_list" cellpadding="0" cellspacing="0">
        <thead>
        <tr>
            <th>Timestamp</th>
            <th>Type</th>
            <th>Channel</th>
            <th>Hotels</th>
            <th>Exception</th>
            <th>Timespan</th>
            <th>Task Id</th>
        </tr>
        </thead>
        <tbody>
        <s:iterator value="paginater.objects">
            <tr <s:if test="error">style="color: #ff0000;"</s:if>>

                <td>
                    <s:date name="timestamp" format="yyyy-MM-dd HH:mm:ss"/>
                </td>
                <td>${operationType}</td>
                <td>${channel}</td>
                <td>${hotels}</td>
                <td>
                    <s:if test="exception.length()>100"><s:property value="exception.substring(0,90)"/>...</s:if>
                    <s:else>${exception}</s:else>
                </td>
                <td>
                    <s:if test="timeSpan>5000">
                        <span style="color:#ff9900;">${timeSpan}</span>
                    </s:if>
                    <s:else>
                        <span style="color:#00cc33;">${timeSpan}</span>
                    </s:else>
                    &nbsp;ms
                </td>
                <td>
                    <a href="view.dhtml?requestCondition.code=${requestCondition.code}&requestCondition.id=${id}">${taskId}</a>
                </td>
            </tr>
        </s:iterator>
        </tbody>
    </table>
    <jsp:include page="../../common/pagination.jsp"/>
</div>

